﻿@namespace MudBlazor.UnitTests.TestComponents

<MudPopoverProvider />
<MudDataGrid T="Model" ShowMenuIcon="true" Items="@_items" Groupable="true">
    <Columns>
        <PropertyColumn Property="x => x.Name" Title="Name" Grouping="true" HeaderClass="name" />
        <PropertyColumn Property="x => x.Age" Title="Age" Grouping="@IsAgeGrouped" HeaderClass="age" />
        <PropertyColumn Property="x => x.Gender" Title="Gender" @bind-Grouping="@IsGenderGrouped" HeaderClass="gender"/>
    </Columns>
</MudDataGrid>

<MudButton Class="GroupByGender" @onclick="GroupByGender">Group By Gender</MudButton>
<MudButton Class="GroupByAge" @onclick="GroupByAge">Group By Age</MudButton>
@code {

    public bool IsGenderGrouped { get; set; }
    public bool IsAgeGrouped { get; set; }

    public List<Model> _items = new List<Model>()
    {
        new Model("John", 45, "Male"), 
        new Model("Johanna", 23, "Female"), 
        new Model("Steve", 32, "Male"),
        new Model("Alice", 32, "Female")
    };

    public record Model(string Name, int Age, string Gender);

    void GroupByGender(MouseEventArgs args)
    {
        IsGenderGrouped = true;
    }

    void GroupByAge(MouseEventArgs args)
    {
        IsAgeGrouped = true;
    }
}
